<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>NormalSystem</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/jquery.js"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <script type="text/javascript" src="./js/role.js"></script>
</head>
  
  <body>
  <div class="x-body">
      <form class="layui-form" lay-filter="adminForm">
          <input type="hidden" id="id" name="id" />
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  <span class="x-red">*</span>角色名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="name" name="name" required="" lay-verify="required"
                         autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="code" class="layui-form-label">
                  <span class="x-red">*</span>角色code
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="code" name="code" required=""
                         autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>
              </div>
          </div>
          <div class="layui-form-item">
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  保存
              </button>
          </div>
      </form>
  </div>
    <script>
        var url = location.href;
        var paraString = url.substring(url.indexOf("?") + 1, url.length);
        if(paraString != url) {
            var obj = new Object();
            obj.id = paraString;
            $.ajax({
                url          : localStorage.getItem("url")+'ms-pms/role/detail/'+paraString,
                method       : 'POST',
                contentType  : 'application/json',
                dataType     : 'json',
                headers      : {"token" : localStorage.getItem("token")},
                data         : JSON.stringify(obj),
                success      : function (res) {
                    if(res.code == 100000) {
                        $("#id").val(res.data.id);
                        $("#code").val(res.data.code);
                        $("#name").val(res.data.name);
                    } else {
                        layer.msg(res.msg);
                    }
                }
            })
        }

    </script>
  </body>

</html>